<template>
  <div class="chat_part" :id="chatPartId">
    <div v-if="isNull" class="null">
      有什么能帮到您吗?
    </div>
    <div v-else class="main-part">
      <div class="question-up">
        <DIV style="color: black;font-size: 20px;font-weight: 600;padding: 10px;display: flex;align-items: center;color: #fff;">
          <img src="/src/views/问题.png" style="width: 25px;height: 25px;margin-right: 5px">
          软件度量代码/图片
        </DIV>
        <div style="height: 1px;width: 220px;background-color: #a0a0a0;"></div>
        <div class="msg_content" style="color: #fff;padding: 20px;" v-if="message.answer">
          {{ message.question }}
        </div>
        <div style="display: flex;" v-else>
          <img src="/src/views/loading.gif" style="margin: 0 auto;">
        </div>
      </div>
      <div class="answer-up">
        <DIV style="color: black;font-size: 20px;font-weight: 600;padding: 10px;color: #fff;">
          <img src="/src/views/回答.png" style="width: 20px;margin-right: 5px">
          度量结果
        </DIV>
        <div style="height: 1.1px;width: 120px;background-color: #a0a0a0;"></div>
        <div class="msg_content" v-if="message.answer">
          {{ message.answer }}
        </div>
        <div style="display: flex;" v-else>
          <img src="/src/views/loading.gif" style="margin: 0 auto;">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ChatMessage',
  props: {
    isNull: {
      type: Boolean,
      default: true
    },
    message: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      chatPartId: 'chat_part'
    }
  }
}
</script>

<style scoped>
.main-part {
  display: flex;
  flex-direction: column;
  width: 1100px;
  height: 80vh;
}

.question-up, .answer-up {
  overflow-y: auto;
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  border-radius: 10px;
  margin-bottom: 10px;
}

.question-up {
  flex: 64;
  background-color: #2f2f2f;
  height: 0vh;
  margin-top: 20px
}

.answer-up {
  flex: 36;
  background-color: #2f2f2f;
}

.chat_part {
  overflow-y: auto;
  font-size: 18px;
  min-width: max(60%,500px);
  max-width: 100%;
  height: 100%;
}

.chat_part::-webkit-scrollbar {
  display: none;
}

.null {
  text-align: center;
  margin-top: 150px;
}

.msg_content {
  white-space: pre-line;
  word-wrap: break-word;
  margin-top: 8px;
  padding: 10px;
  min-width: 50px;
  border-radius: 15px;
  text-align: left;
}
</style> 